-
Notifications
You must be signed in to change notification settings - Fork 1k
Python: Create/Get Agent API for Azure V2 #3059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a new AzureAIProjectAgentProvider class for creating and managing Azure AI agents using the Azure AI Projects SDK V2. This provides a cleaner, provider-based API pattern for agent creation and retrieval.
Changes:
- Introduces
AzureAIProjectAgentProviderwith methods:create_agent(),get_agent(), andas_agent() - Refactors shared utility functions for tool conversion between Azure AI and Agent Framework formats
- Updates all Azure AI samples to use the new provider pattern instead of direct client usage
- Adds comprehensive unit and integration tests for the provider
- Updates exports and type stubs to include the new provider class
Reviewed changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
python/packages/azure-ai/agent_framework_azure_ai/_provider.py |
New provider implementation with create, get, and wrap agent methods |
python/packages/azure-ai/agent_framework_azure_ai/_shared.py |
Shared utilities for tool conversion and response format handling |
python/packages/azure-ai/agent_framework_azure_ai/_client.py |
Refactored to use shared create_text_format_config function |
python/packages/azure-ai/agent_framework_azure_ai/__init__.py |
Updated exports to include AzureAIProjectAgentProvider |
python/packages/azure-ai/agent_framework_azure_ai/__init__.pyi |
Type stub updated with new provider |
python/packages/core/agent_framework/azure/__init__.py |
Lazy import configuration for new provider |
python/packages/core/agent_framework/azure/__init__.pyi |
Type stub for main package |
python/packages/azure-ai/tests/test_provider.py |
Comprehensive unit tests for provider functionality |
python/packages/azure-ai/tests/test_azure_ai_client.py |
Added tests for tool parsing utilities |
python/samples/getting_started/agents/azure_ai/*.py (20+ files) |
All samples updated to use provider pattern |
python/samples/getting_started/agents/azure_ai/azure_ai_provider_methods.py |
New comprehensive sample demonstrating all provider methods |
python/samples/getting_started/agents/azure_ai/README.md |
Updated to describe new provider and sample |
| model: str | None = None, | ||
| instructions: str | None = None, | ||
| description: str | None = None, | ||
| temperature: float | None = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then we can make this typed as well, probably using a subset of the "regular" options.
python/samples/getting_started/agents/azure_ai/azure_ai_provider_methods.py
Show resolved
Hide resolved
python/samples/getting_started/agents/azure_ai/azure_ai_with_explicit_settings.py
Show resolved
Hide resolved
| self._should_close_client = True | ||
|
|
||
| self._project_client = project_client | ||
| self._credential = credential |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see us using self._credential anywhere. Do we need to hold on to it?
| ServiceInitializationError: If required parameters are missing or invalid. | ||
| """ | ||
| try: | ||
| self._settings = AzureAISettings( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The V2 client initialization pattern (settings creation, endpoint/credential validation, AIProjectClient instantiation with user-agent) is now repeated between AzureAIProjectAgentProvider and AzureAIClient. Worth a shared helper, or acceptable given the localized scope?
Motivation and Context
This PR contains an implementation of create/get API with
Providertype for Azure AI V2 chat client, based on Option 2 from this ADR.Example:
Contribution Checklist